
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MyIM.client;

import MyIM.client.engine.Engine;
import MyIM.client.view.ClientView;
import MyIM.client.view.form.Dialog_Chat;
import MyIM.client.view.form.Dialog_Conference;
import MyIM.client.view.form.Dialog_Confirm;
import MyIM.client.view.form.Dialog_Login;
import MyIM.client.view.lnf.MetroStyle;
import MyIM.client.view.lnf.Style;
import MyIM.component.Group;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Observable;
import java.util.Observer;
import javax.swing.ImageIcon;

/**
 *
 * @author satthuvdh
 */
public class Client implements Observer {

    private int uid;
    private String username;
    private String displayName;
    private ImageIcon avatar;
    private ArrayList<Group> groupList;
    private HashMap<Integer, Dialog_Chat> listChat;
    private HashMap<String, Dialog_Conference> listConference;
    private ClientView view;

    public static void main(String[] args) {
        MetroStyle.setLookAndFeel(Style.LIGHT);
        Engine engine = new Engine();
        new Dialog_Login(engine);
    }

    public Client(int uid, String username, String displayName, ImageIcon image) {
        this.uid = uid;
        this.username = username;
        groupList = new ArrayList<>();
        this.displayName = displayName;
        this.avatar = image;
        this.listChat = new HashMap<>();
        groupList = new ArrayList<>();
        listConference = new HashMap<>();
    }

    public Client() {
    }

    public int getUID() {
        return uid;
    }

    public String getUsername() {
        return username;
    }

    @Override
    public void update(Observable o, Object arg) {
        // TODO finish here
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public ArrayList<Group> getFriendList() {
        return this.groupList;
    }

    public void setFriendList(ArrayList<Group> friendList) {
        this.groupList = friendList;
    }

    public String getDisplayName() {
        return displayName;
    }

    public ImageIcon getAvatar() {
        return avatar;
    }

    public String[] getGroupNameList() {
        ArrayList<String> groupNames = new ArrayList<String>();
        for (Group group : groupList) {
            groupNames.add(group.getGroupName());
        }
        return groupNames.toArray(new String[groupList.size()]);
    }

    public HashMap<Integer, Dialog_Chat> getListChat() {
        return listChat;
    }

    public HashMap<String, Dialog_Conference> getListConference() {
        return listConference;
    }

    public void addGroupObj(Group g) {
        groupList.add(g);
    }

    public ClientView getView() {
        return view;
    }

    public void setCientView(ClientView view) {
        this.view = view;
    }

    public void addNewDialogChat(int fid, Dialog_Chat dialog) {
        listChat.put(fid, dialog);
    }

    public void addNewDialogConfirm(Dialog_Confirm dialog) {
        
    }
    
    
}

